/*******************************************************************************
* 1. 시 스 템 : 농협보험 이미지처리 시스템
* 2. 프로그램 : ConnectionPool.java
* 3. 개 요 : DBConnection을 Pool로 관리한다.
* 4. 작 성 자 : 손 영휘
* 5. 작 성 일 : 2011. 09. 30
* 6. 소스버전 : 1.0
********************************************************************************/
package com.nhim.pool;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class ConnectionPool 
{
	public static Connection getConnection() throws SQLException {
		return DBConnection.getInstance().getConnection();
	}
	

	public static void close(Connection conn) {
		DBConnection.getInstance().freeConnection(conn);
	}
	
	
	public static void close(
						ResultSet rs, 
						PreparedStatement pstmt, 
						Connection conn) {
		try {
			if (rs != null) {rs.close();} 
			if (pstmt != null) {pstmt.close();} 
			close(conn);
		}catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public static void close(
					ResultSet rs, 
					Statement stmt, 
					Connection conn){
		try {
			if (rs != null) {rs.close();} 
			if (stmt != null) {stmt.close();} 
			close(conn);
		}catch (SQLException e) {
			e.printStackTrace();
		}
	}

	public static void close(Statement stmt, Connection conn) {
		try {
			if (stmt != null) {stmt.close();} 
			close(conn);
		}catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public static void close(PreparedStatement pstmt, Connection conn) {
		try {
			if (pstmt != null) {pstmt.close();} 
			close(conn);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}		
}